package com.tsu.mall.common.config;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;

import java.util.ArrayList;
import java.util.List;

@Configuration
@EnableJms
public class ActiveMQConfig {

    @Bean
    public ActiveMQConnectionFactory factory(@Value("tcp://localhost:61616") String url) {
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url);
        // 设置信任序列化包集合
        List<String> models = new ArrayList<>();
        //　Integer　哪些包的类型是可以信任的　　类型必须 implements Serializable
        models.add("java.lang");
        factory.setTrustedPackages(models);
        return factory;
    }

}
